﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.WinKStart
 * 
 * Description: Enum and Convert Class to work with XML horizontalAlign 
 * 
 * Created:     22.07.2012
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.de
 * 
 * Lizense:     GPLv3
 * 
 * History:     22.07.2012 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WMSSoft.Lib.Enums
{
    /// <summary>
    /// Use the enum to describe horizontal align for a Textstring in a StartMenuItem
    /// </summary>
    public enum eXMLHorizontalAlign
    {
        /// <summary>
        /// Horizontal Align is unknown
        /// </summary>
        Unknown = 0,

        /// <summary>
        /// Horizontal Text Align on the left side
        /// </summary>
        Left = 1,

        /// <summary>
        /// Horizontal Text Align is center
        /// </summary>
        Center,

        /// <summary>
        /// Horizontal Text Align on the right side
        /// </summary>
        Right, 

        /// <summary>
        /// Text will be shown as blockset
        /// </summary>
        Justify
    }

    /// <summary>
    /// Methods to Convert a string to a eXMLHorizontalAlign or a eXMLHorizontalAlign to a string
    /// </summary>
    public static class cXMLHorizontalAlign
    {
        /// <summary>
        /// Methode converts a string to a eXMLHorizontalAlign
        /// </summary>
        /// <param name="Value">string to get a eXMLHorizontalAlign</param>
        /// <returns>eXMLHorizontalAlign, Unknown if the string value is unknown</returns>
        public static eXMLHorizontalAlign GetEnumValueFromString(string Value)
        {
            try
            {
                if (Value.ToUpper() == "LEFT") return eXMLHorizontalAlign.Left;
                else if (Value.ToUpper() == "CENTER") return eXMLHorizontalAlign.Center;
                else if (Value.ToUpper() == "RIGHT") return eXMLHorizontalAlign.Right;
                else return eXMLHorizontalAlign.Unknown;
            }
            catch
            {
                return eXMLHorizontalAlign.Unknown;
            }
        }

        /// <summary>
        /// Methode converts a eXMLHorizontalAlign to a string
        /// </summary>
        /// <param name="Value">eXMLHorizontalAlign Value</param>
        /// <returns>string equivalent to the value</returns>
        public static string GetStringFromEnum(eXMLHorizontalAlign Value)
        {
            try
            {
                switch (Value)
                {
                    case eXMLHorizontalAlign.Left: return "Left";
                    case eXMLHorizontalAlign.Center: return "Center";
                    case eXMLHorizontalAlign.Right: return "Right";
                    default: return "Unknown";
                }
            }
            catch
            {
                return "Unknown";
            }
        }
    }
}
